<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------
/**
 * Class CertifiedDrivingAgent
 * Desc  认证代驾校验
 * Create on 2024/10/26 10:36
 * Create by wangyafang
 */

namespace app\api\validate\wddj\driver;


use think\Validate;

class CertifiedDrivingAgent extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name'=>'require',
        'id_card'=>'require|checkIdCard',
        'driving_experience'=>'require',
        'driver_license_type'=>'require',
        'front_id_card'=>'require',
        'front_vehicle_driver_license'=>'require',
        'address'=>'require',
        'longitude'=>'require',
        'latitude'=>'require',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'name.require'=>'请输入姓名',
        'id_card.require'=>'请输入身份证号',
        'driving_experience.require'=>'请选择驾龄',
        'driver_license_type.require'=>'请选择驾照类型',
        'front_id_card.require'=>'请上传身份证正面图片',
        'front_vehicle_driver_license.require'=>'请上传车辆驾驶证正面图片',
        'address.require'=>'请填写居住地址',
        'longitude.require'=>'定位获取失败',
        'latitude.require'=>'定位获取失败',
    ];

    protected function checkIdCard($value,$rule,$data)
    {
        $id_card_pattern = '/^\d{17}[0-9xX]$/';
        if (!preg_match($id_card_pattern, $value)) {
            return "身份证号码格式不正确！";
        }
        return true;
    }
}



 